<template>
  <!-- 颜色选择器 -->
  <div class="pho-form-item" :style="newStyle">
    <van-field
      v-bind="$attrs"
      :label="showLabel ? $attrs.label : ''"
      :name="$attrs.__vModel__"
      :required="$attrs.required"
      :rules="$attrs.regList"
      :placeholder="$attrs.placeholder"
      input-align="right"
    >
    <template #label>
      <span v-if="showLabel" slot="label" :style="newStyle.font">{{$attrs.label}}</span>
    </template>
      <template #input></template>
    </van-field>
  </div>
</template>

<script>
import { comMixin } from "../../../utils/comMixins";
export default {
  mixins: [comMixin],
  name: "phone-form-color-picker",
  model: {
    prop: "value", // 绑定的值，通过父组件传递
    event: "update",
  },
  props: {
    value: {
      type: [Number, String],
      default: "",
    },
    // 是否展示标题
    showLabel: {
      type: Boolean,
      default: true,
    },
  },
  data() {
    return {
      formValue: "",
    };
  },
  watch: {
    value: {
      immediate: true,
      deep: true,
      handler(newValue) {
        this.formValue = newValue;
      },
    },
  },
  methods: {
    handleChange(val) {
      this.$emit("update", val);
      this.$emit("change", val);
      this.onChange(val);
    },
  },
};
</script>

<style lang="scss" scoped></style>
